<?php

namespace app\model\product\product;

use app\model\product\sku\StoreProductLabelRelation;
use crmeb\basic\BaseModel;
use crmeb\traits\ModelTrait;

class StoreProductLabel extends BaseModel
{

    use ModelTrait;
    /**
     * 表名
     * @var string
     */
    protected $name = 'store_product_labels';

    /**
     * 主键
     * @var string
     */
    protected $pk = 'id';

    /**
     * @param Model $query
     * @param $value
     */
    public function searchNameAttr($query, $value)
    {
        $query->whereLike('name', '%' . $value . '%');
    }

    /**
     * 一对多关联
     * @return \think\model\relation\HasMany
     */
    public function label()
    {
        return $this->hasMany(StoreProductLabelRelation::class, 'label_id', 'id');
    }
}